package crm.system.util;

public class Page {
	private int pageNo;
	private int pageSize;
	private int totalCount;
	private int totalPages;

	public int getPageNo() {
		if(pageNo==0){
			pageNo=1;
		}
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		if (pageNo > 0) {
			this.pageNo = pageNo;
		}else{
			this.pageNo=1;
		}

	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		if (pageSize > 0) {
			this.pageSize = pageSize;
		}
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		if (totalCount > 0) {
			this.totalCount = totalCount;
			//this.setTotalPages();
		}
	}

	public int getTotalPages() {
		if (totalPages != 0) {
			return totalPages;
		}
		return pageNo;
	}

	public void setTotalPages() {
		if (this.totalCount % this.pageSize == 0) {
			this.totalPages = this.totalCount / this.pageSize;
		} else if (this.totalCount % this.pageSize > 0) {
			this.totalPages = this.totalCount / this.pageSize + 1;
		} else {
			this.totalPages = 0;
		}
	}

}
